package org.crmsystem.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;










import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.crmsystem.dao.IAppointMapper;
import org.crmsystem.model.Appoint;
import org.crmsystem.service.IAppointService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 预约业务实现类
 * @author Administrator
 *
 */
@Service
public class AppointServiceImpl implements IAppointService{

	private static Logger logger=LogManager.getLogger(AppointServiceImpl.class);
	
	@Autowired
	private IAppointMapper appointMapper;

	/**
	 * 创建预约
	 */
	public int insertAppoint(Appoint appoint) throws Exception {
		int flag=appointMapper.insertAppoint(appoint);
		return flag;		
	}
	
	/**
	 * 删除预约
	 */
	public int deleteAppoint(int id) {
		int flag=appointMapper.deleteAppoint(id);
		return flag;
	}
	/**
	 * 编辑预约
	 */
	public int updateAppointById(Appoint appoint) throws Exception {
		int flag=appointMapper.updateAppointById(appoint);
		return flag;
	}

	/**
	 * 多条件查询
	 */
	public List<Appoint> getAppointByKeyword(String type,String keyword) {
		Map<String,String> ma=new HashMap<String, String>();
		ma.put("type", type);
		ma.put("keyword", keyword);
		
		List<Appoint> list=appointMapper.getAppointByKeyword(ma);
		return list;
	}

	/**
	 * 根据id查询预约信息 
	 */
	public Appoint getAppById(int id) {
		Appoint appoint=appointMapper.getAppById(id);
		return appoint;
	}


}
